# $Id: models.py 7557b5d4d82b 2012/12/02 09:07:16 pgurumur $
# Copyright (c) 2009 Prabhu Gurumurthy  <pgurumur@gmail.com>
# 
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#
from django.db import models

from djanet.db import models as model
from djanet.db import netdb
from djanet.lib import ip, stdlib

__version__ = "$Revision: 7557b5d4d82b $"
__author__ = "$Author: pgurumur $"

class syslog(model.BaseModel):
   log_timestamp = models.DateTimeField(help_text = "syslog server timestamp",
         name = "timestamp")
   device = models.ForeignKey(netdb.Device)
   log_text = models.TextField(help_text = "Logged string")
   checksum = models.CharField(max_length = 128,
         help_text = "Logged string checksum")

   class Meta:
      db_table = u'syslog'
      ordering = ['log_timestamp']

class flows(model.BaseModel):
   tag = models.IntegerField(help_text = "tag value for flow")
   received = models.DateTimeField(help_text = "received timestamp")
   src_addr = models.IPAddressField(
         help_text = "source address", name = "src_addr")
   dst_addr = models.IPAddressField(help_text = "destinarion address",
         name = "dst_addr")
   agent_addr = models.IPAddressField(help_text = "Agent address",
         name = "dst_addr")
   src_port = models.IntegerField(help_text = "source port")
   dst_port = models.IntegerField(help_text = "destination port")
   octets = models.IntegerField(help_text = "Octets")
   packets = models.IntegerField(help_text = "Number of packets received")
   protocol = models.IntegerField(help_text = "Protocol used")

   class Meta:
      db_table = u'flows'
      ordering = ['received']

   def __str__(self):
      return stdlib.my_str(self.agent_addr)
